//
//  DetailAbilityViewController.m
//  LOL_JewelBox
//
//  Created by dllo on 15/4/25.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "DetailAbilityViewController.h"
#import "AFHTTPRequestOperationManager.h"
#import "UIImageView+WebCache.h"
#import "DetailModel.h"
#import "ToolsView.h"

@interface DetailAbilityViewController ()

@property(nonatomic, retain)ToolsView *toolsView;
@property(nonatomic, retain)UIScrollView *scrollView;
@property(nonatomic, retain)UIScrollView *scrollView2;

@property(nonatomic, retain)NSMutableArray *transformArr;

@property(nonatomic, retain)UILabel *nameLabel;     // 名称
@property(nonatomic, retain)UILabel *levelLabel;    // 学习该技能所需等级
@property(nonatomic, retain)UILabel *coolDownLabel; // 技能冷却时间
@property(nonatomic, retain)UILabel *desLabel;      // 技能详解
@property(nonatomic, retain)UILabel *tipsLabel;     // 温馨提示

@end

@implementation DetailAbilityViewController

- (void)dealloc
{
    
    [_toolsView release];
    [_scrollView release];
    [_scrollView2 release];
    [_transformArr release];
    [_nameLabel release];
    [_levelLabel release];
    [_coolDownLabel release];
    [_desLabel release];
    [_tipsLabel release];
    [super dealloc];
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
    // 铺设自定义View
    self.toolsView = [[ToolsView alloc] initWithFrame:CGRectMake(0, 0, VIEWWIDTH, VIEWHEIGHT)];
    [self.view addSubview:self.toolsView];
    self.toolsView.backgroundColor = [UIColor colorWithRed:218 / 255.0 green:218 / 255.0 blue:218 / 255.0 alpha:1];
    [_toolsView release];
    
    
    // 图片位置
    UIImageView *detailPng = [[UIImageView alloc] initWithFrame:CGRectMake(20, 20, 100, 100)];
    NSString *strPng = [NSString stringWithFormat:@"http://img.lolbox.duowan.com/spells/png/%@.png", self.detailAbilityid];
    NSURL *url = [NSURL URLWithString:strPng];
    [detailPng sd_setImageWithURL:url];
    [self.toolsView addSubview:detailPng];
    [detailPng release];
    
    self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(31, 161, VIEWWIDTH - 62, VIEWHEIGHT / 6.7)];
    self.scrollView.contentSize = CGSizeMake(VIEWWIDTH - 62, 200);
    [self.toolsView addSubview:self.scrollView];
    self.scrollView.layer.cornerRadius = 10;
    self.scrollView.backgroundColor = [UIColor colorWithRed:230 / 255.0 green:230 / 255.0 blue:230 / 255.0 alpha:1];
    [_scrollView release];
    
    self.scrollView2 = [[UIScrollView alloc] initWithFrame:CGRectMake(31, VIEWHEIGHT / 6.7 + 191, VIEWWIDTH - 62, VIEWHEIGHT / 5.21)];
    self.scrollView2.contentSize = CGSizeMake(VIEWWIDTH - 62, 200);
    [self.toolsView addSubview:self.scrollView2];
    self.scrollView2.layer.cornerRadius = 10;
    self.scrollView2.backgroundColor = [UIColor colorWithRed:230 / 255.0 green:230 / 255.0 blue:230 / 255.0 alpha:1];
    [_scrollView2 release];
    
    [self createView];

    
}

// 详情
- (void)createView
{
    
    // 名称
    UILabel *name = [[UILabel alloc] initWithFrame:CGRectMake(130, 20, 50, 30)];
    name.text = @"名称:";
    name.font = [UIFont fontWithName:@"Helvetica-Bold" size:18];
    [self.toolsView addSubview:name];
    [name release];
    self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(175, 20, 150, 30)];
    self.nameLabel.text = self.detailAbilityName;
    [self.toolsView addSubview:self.nameLabel];
    [_nameLabel release];
    
    // 所需玩家等级
    UILabel *level = [[UILabel alloc] initWithFrame:CGRectMake(130, 55, 60, 30)];
    level.text = @"需等级:";
    level.font = [UIFont fontWithName:@"Helvetica-Bold" size:18];
    [self.toolsView addSubview:level];
    [level release];
    self.levelLabel = [[UILabel alloc] initWithFrame:CGRectMake(190, 55, 100, 30)];
    self.levelLabel.text = self.detailAbilityLevel;
    [self.toolsView addSubview:self.levelLabel];
    [_levelLabel release];
    
    // 技能冷却时间
    UILabel *down = [[UILabel alloc] initWithFrame:CGRectMake(130, 90, 80, 30)];
    down.text = @"冷却时间:";
    down.font = [UIFont fontWithName:@"Helvetica-Bold" size:18];
    [self.toolsView addSubview:down];
    [down release];
    self.coolDownLabel = [[UILabel alloc] initWithFrame:CGRectMake(210, 90, 100, 30)];
    self.coolDownLabel.text = self.detailAbilityCooldown;
    [self.toolsView addSubview:self.coolDownLabel];
    [_coolDownLabel release];
    
    
    // 技能详解
    UILabel *textdescription = [[UILabel alloc] initWithFrame:CGRectMake(30, 130, 100, 30)];
    textdescription.text = @"技能详解:";
    textdescription.font = [UIFont fontWithName:@"Helvetica-Bold" size:18];
    [self.toolsView addSubview:textdescription];
    [textdescription release];
    
    self.desLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0 , VIEWWIDTH - 62, 150)];
    self.desLabel.text = self.detailAbilityDes;
    [self.scrollView addSubview:self.desLabel];
    self.desLabel.numberOfLines = 0;
    self.desLabel.lineBreakMode = NSLineBreakByCharWrapping;
    [self.desLabel sizeToFit];
    [_desLabel release];
    
    // 温馨提示
    UILabel *prompt = [[UILabel alloc] initWithFrame:CGRectMake(30, VIEWHEIGHT / 6.7 + 161, 100, 30)];
    prompt.text = @"温馨提示:";
    prompt.font = [UIFont fontWithName:@"Helvetica-Bold" size:18];
    [self.toolsView addSubview:prompt];
    [prompt release];
    
    self.tipsLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, VIEWWIDTH - 62, 130)];
    self.tipsLabel.text = self.detailAbilityTips;
    [self.scrollView2 addSubview:self.tipsLabel];
    self.tipsLabel.numberOfLines = 0;
    self.tipsLabel.lineBreakMode = NSLineBreakByCharWrapping;
    [self.tipsLabel sizeToFit];
    [_tipsLabel release];
    
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
